import {
  Image as ImageLayer,
  Group as LayerGroup,
  Vector as VectorLayer,
  Heatmap,
} from "ol/layer";
import { ImageStatic, Vector as VectorSource } from "ol/source";
import { GeoJSON } from "ol/format";

/**
 * 本地静态图片图层
 */
export function getLocalImage() {
  // 降雨图1
  const rainImageLayer1 = new ImageLayer({
    properties: {
      name: "降雨图1号",
      id: "rainfall_1",
    },
    source: new ImageStatic({
      url: "src/examples/图层/图片图层/img/rainfall_1.png",
      imageExtent: [109.654314, 20.21473, 117.31375, 26.087337],
    }),
  });

  // 降雨图2
  const rainImageLayer2 = new ImageLayer({
    properties: {
      name: "降雨图2号",
      id: "rainfall_2",
    },
    source: new ImageStatic({
      url: "src/examples/图层/图片图层/img/rainfall_2.png",
      imageExtent: [109, 20, 117, 26],
    }),
  });

  return new LayerGroup({
    properties: {
      name: "降雨图",
      id: "rainfall",
    },
    layers: [rainImageLayer1, rainImageLayer2],
    zIndex: 10,
  });
}

/**
 * 热力图
 */
export function getWeatherStationHeatMap() {
  const weatherStationSource = new VectorSource({
    format: new GeoJSON(),
    url: "src/data/气象站点/stations-wgs.geojson",
  });

  const heatMapLayer = new Heatmap({
    properties: {
      id: "weather_station_heat_map",
      name: "气象站点热力图",
    },
    source: weatherStationSource,
    blur: 15,
    radius: 8,
  });

  return heatMapLayer;
}
